 package com.icangya.DAO.impl;


import com.icangya.DAO.IKicKBallDAO;
import com.icangya.Utils.SQLUtilt;
import com.icangya.domain.KicKBall;
import org.springframework.stereotype.Repository;


import java.util.List;

import static com.icangya.Value.FootBall.FOOT_PAGE_ROW;
import static com.icangya.Value.StaticValue.PHONE_PAGE_ROW;

 @Repository
public class KicKBallDAOImpl extends  BaseDAO<KicKBall> implements IKicKBallDAO {
    @Override
    public List getKicBallByOpenId(String openId) {

        String hql="FROM KicKBall k where k.openId=? order by k.kickBallTime desc";
       List<KicKBall> list= (List<KicKBall>) getHibernateTemplate().find(hql,openId);
       // SQLUtilt.getIstance().doPage(getHibernateTemplate(),hql,startPage,PHONE_PAGE_ROW,openId);
        if (list != null && list.size() >0 )
            return list;
        return null;
    }

     @Override
     public List getKicBallByOpenId(String openId,int startPage) {

         String hql="FROM KicKBall k where k.openId='"+openId+"' order by k.kickBallTime desc";
         String count = "SELECT COUNT(k) " + hql;
         Long total = (Long) getHibernateTemplate().find(count).get(0);

         return SQLUtilt.getIstance().doPage(getHibernateTemplate(), hql, total, startPage, FOOT_PAGE_ROW);

//         if (list != null && list.size() >0 )
//             return list;
//         return null;
     }
}
